#pragma once
#include <cstdint>
#include <memory>
#include <string>
#include <iostream>
#include <odb/database.hxx>
#include <odb/mysql/database.hxx>
#include "logger.hpp"

namespace shared {

namespace dal {     // data-access-layer

using OdbPtr = std::shared_ptr<odb::mysql::database>;

class ODBFactory
{
public:
    static OdbPtr create(
        const std::string& user, const std::string& passwd,
        const std::string& host, const std::string& db, const std::string& cset,
        uint16_t port, uint16_t connectPoolCount)
    {
        std::unique_ptr<odb::mysql::connection_pool_factory> cpf = 
            std::make_unique<odb::mysql::connection_pool_factory>(connectPoolCount, 0);
        
        return std::make_shared<odb::mysql::database>(
            user, passwd, db, host, port, "", cset, 0, std::move(cpf)
        );
    }

};

}}